﻿
@{
    ViewBag.Title = "帮助中心";
    Layout = "~/Views/Shared/_MallLayout.cshtml";
}
<body class="page-qaq page-qaqResult">
    <div class="bg-white mescroll " id="mescroll">
        <div class="mod-search">
            <div class="searchBox bg-white radius flex">
                <div class="searchBtn flex-box">
                    <i class="icon-sc"></i>
                </div>
                <input class="searchInput fn30 flex-1" type="text" placeholder="请输入需要搜索的问题" id="keyword" autocomplete="off" value="@(!string.IsNullOrEmpty(Request["keyword"])? Request["keyword"] : "")">
                <a id="search_btn" href="javascript:void(0);" class="searchNow cur fn30">搜索</a>
            </div>
        </div>
        <div >
            <div class="qaqList bg-white fn28" id="datalist">

            </div>
        </div>

    </div>
    <style>
        .mescroll {
            position: fixed;
            top: 0;
            width: 100%;
            bottom: 0;
            height: auto;
        }
    </style>
    <link href="~/Scripts/mescroll/mescroll.min.css" rel="stylesheet" />
    <script src="~/Scripts/mescroll/mescroll.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#keyword").focus();
            var keyword = '@(!string.IsNullOrEmpty(Request["keyword"])? Request["keyword"] : "")';
            var mescroll = new MeScroll("mescroll", {
                down: {
                    auto: false,
                    callback: function (mescroll) {
                        mescroll.resetUpScroll(); //下拉刷新的回调,默认重置上拉加载列表为第一页
                    }
                },
                up: {
                    callback: getListData,
                    clearEmptyId: "datalist",
                    isBounce: false,
                    noMoreSize: 3,
                    htmlNodata: '<p class="upwarp-nodata">--没有更多数据了 --</p >',
                    empty: {
                        warpId: "datalist",
                        icon: "",
                        tip: "亲,没有您要找的问题~"

                    },
                    toTop: {
                        src: "/Content/css/tokenmall/img/toup.png",
                        html: " <img src='/Content/css/tokenmall/img/toup.png' />",
                        offset: 500
                    }
                }
            });

            function getListData(page) {
                $.ajax({
                    type: 'post',
                    url: '/user/_Help',
                    data: { page: page.num, size: page.size, title: keyword },
                    success: function (response) {
                        var paged = $(response).siblings("page");
                        var rows = Number.parseInt(paged.attr("rows"));
                        var total = Number.parseInt(paged.attr("total_result"));
                        mescroll.endBySize(rows, total);
                        if (paged.length === 1) {
                            $("#datalist").append($(response));
                            $('#datalist page').remove();
                        }

                    },
                    error: function (e) {
                        //联网失败的回调,隐藏下拉刷新和上拉加载的状态
                        mescroll.endErr();
                    }
                });
            }
            $("#keyword").blur(function () {
                keyword = $("#keyword").val();
                if (keyword.length > 0) {
                    document.activeElement.blur();
                    //重置列表数据
                    mescroll.resetUpScroll();
                    //隐藏回到顶部按钮
                    mescroll.hideTopBtn();
                }
            });
            $("#keyword").keyup(function (event) {
                if (event.keyCode == 13) {
                    keyword = $("#keyword").val();
                    if (keyword.length > 0) {
                        document.activeElement.blur();
                        //重置列表数据
                        mescroll.resetUpScroll();
                        //隐藏回到顶部按钮
                        mescroll.hideTopBtn();
                    }
                }
            });

            $("#search_btn").click(function () {
                keyword = $("#keyword").val();
                if (keyword.length > 0) {
                    document.activeElement.blur();
                    //重置列表数据
                    mescroll.resetUpScroll();
                    //隐藏回到顶部按钮
                    mescroll.hideTopBtn();
                }
            })
        })
    </script>
</body>
